﻿@using WI.CandidateManager.Common.Data.Enums
@model WI.CandidateManager.Common.Data.Entities.Test

@{
    ViewBag.Title = @Resources.Common.CommonTestEdit;
}

<h2>@Resources.Common.CommonTestEdit</h2>

@using (Html.BeginForm("Edit", "Tests", new { @TestId = Model.Id }, FormMethod.Post))
{
    @Html.ValidationSummary(true)
    
    <table class="bordered">
        <tr>
            <td class="vertical-header">@Html.LabelFor(model => model.Name)</td>
            <td>@Html.EditorFor(model => model.Name, new { @class = "" })</td>
        </tr>
        <tr>
            <td class="vertical-header">@Html.LabelFor(model => model.Description)</td>
            <td>@Html.TextAreaFor(model => model.Description, new { @class = "common-textarea-wide" })</td>
        </tr>
        <tr>
            <td class="vertical-header">@Html.LabelFor(model => model.State)</td>
            <td>@Html.DropDownListFor(model => model.State, new SelectList(Enum.GetValues(typeof(State))))</td>
        </tr>
        <tr>
            <td class="vertical-header">@Html.LabelFor(model => model.Owner.FullName)</td>
            <td>@Html.DisplayFor(model => model.Owner.FullName)</td>
        </tr>
        <tr>
            <td class="vertical-header">Attachments</td>
            <td>@Html.ActionLink("Attachments (" + Model.Attachment.Count + ")", "List", "Attachment", new { area = "", entityID = Model.Id, returnUrl = this.Request.RawUrl }, new { @class = "common-btn BlueColor" })</td>
        </tr>
    </table>
    
    <h3>@Resources.Common.CommonQuestionList</h3>
    
    <p>@Html.ActionLink(@Resources.Common.CommonButtonCreateQuestion, "CreateQuestion", new { @TestId = Model.Id }, new { @class = "common-btn BlueColor" })</p>
   
    <table class="bordered">
        <thead>
            <tr>
                <th>@Resources.Common.CommonButtonEdit</th>
                <th>@Resources.Common.CommonColumnAnswerText</th>
                <th>@Resources.Common.CommonColumnAnswers</th>
                <th>@Resources.Common.CommonButtonDelete</th>
            </tr>
        </thead>
        @foreach (var question in Model.QuestionBase)
        {
            if (question.State == State.Active)
            {
            <tr>
                <td class="Center column-detail">@Html.ActionLink(@Resources.Common.CommonButtonEdit, "EditQuestion", new { @QuestionId = question.Id }, new { @class = "common-btn BlueColor" })</td>
                <td>@question.Text</td>
                <td>@question.AnswerBase.Count</td>
                <td class="Center column-delete">@Html.ActionLink(@Resources.Common.CommonButtonDelete, "DeleteQuestion", new { @QuestionId = question.Id }, new { @class = "common-btn RedColor" })</td>
            </tr>
            }
        }
    </table>
    
    <p>
        @Html.ActionLink(@Resources.Common.CommonButtonCancel, "List", "Tests", new { @class = "common-btn-large BlueColor" })
        <input class="common-btn-large BlueColor" type="submit" value=@Resources.Common.CommonButtonSave />
    </p>
}